<?php

if (!function_exists('test_helper')) {

    function test_helper()
    {
        return 'OK';
    }

}


if (!function_exists('zm_json_encode')) {
    function zm_json_encode($data)
    {
        return json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
    }
}

if (!function_exists('zm_json_decode')) {
    function zm_json_decode($json)
    {
        return json_decode($json, true);
    }
}

if (!function_exists('get_user_id')) {
    function get_user_id()
    {
        return auth()->id() ?? 1;
    }
}

if (!function_exists('cal_total_price')) {
    function cal_total_price($price, $num)
    {
        return round($price * $num, 2);
    }
}

if (!function_exists('cal_price')) {
    function cal_price($totalPrice, $num)
    {
        if ($totalPrice == 0 || $num == 0) {
            return 0;
        }
        return round($totalPrice / $num, 2);
    }
}
